import router from "@/router";
import type { RouteRecord } from 'vue-router'
const pages = import.meta.glob('@/views/pages/**/**.vue')
console.log(pages)
// const router=useRouter() 
export function DynamicRouter(list:any){
  // console.log(list)
    // console.log(router.getRoutes())
    list.forEach((z?:any) => {
        router.addRoute('index',{
           path:z.url,
           name:z.url,
           component: pages['/src/views' + z.url + '.vue'],
          meta:{
            menu_id:z.menu_id
          },
          children: []
        })
        if(z.children){
       DynamicRouter(z.children)
       
        }
    });
   }
   console.log(pages)
   export function removeRoute() {
    router.getRoutes().forEach((v: RouteRecord) => {
      if (v.meta.dynamic) {
        router.removeRoute(v.name as string)
      }
    })
  }
   